<!--
 * @FilePath     : /study_code/jquery/plugin-jquery-tmpl-wrap.html
 * @Description  : wrap  模板语法：包装器
 * @Date         : 2025-04-21 14:49:54
 * @Author       : Fang YingGui
 * @LastEditors  : fangyinggui 18715384437@163.com
 * @LastEditTime : 2025-04-21 14:50:09
-->
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>documentName</title>
  </head>
  <body>
    <div id="wrapDemo"></div>

    <!-- T1：不使用包装器 -->
    <!-- <script id="myTmpl" type="text/x-jquery-tmpl">
      The following wraps and reorders some HTML content:
      <h3>One</h3>
      <div>
        First <b>content</b>
      </div>
      <h3>Two</h3>
      <div>
        And <em>more</em> <b>content</b>...
      </div>
    </script> -->

    <!-- T2：使用包装器 -->
    <script id="myTmpl" type="text/x-jquery-tmpl">
      The following wraps and reorders some HTML content:
      {{wrap "#tableWrapper"}}
          <h3>One</h3>
          <div>
              First <b>content</b>
          </div>
          <h3>Two</h3>
          <div>
              And <em>more</em> <b>content</b>...
          </div>
      {{/wrap}}
    </script>

    <script id="tableWrapper" type="text/x-jquery-tmpl">
      <table cellspacing="0" cellpadding="3" border="1"><tbody>
          <tr>
              {{each $item.html("h3", true)}}
                  <td>
                      ${$value}
                  </td>
              {{/each}}
          </tr>
          <tr>
              {{each $item.html("div")}}
                  <td>
                      {{html $value}}
                  </td>
              {{/each}}
          </tr>
      </tbody></table>
    </script>

    <script src="/jquery/dist/jquery.min.js"></script>
    <script src="/jquery/plugins/jquery.tmpl/lib/jquery.tmpl.min.js"></script>
    <script>
      $(function () {
        var users = [
          { id: 'think8848', name: ['Joseph', 'Chan'] },
          { id: 'aCloud', name: ['Mary', 'Cheung'] },
        ]
        $('#myTmpl').tmpl().appendTo('#wrapDemo')
        $('#tableWrapper').tmpl(users)
      })
    </script>
  </body>
</html>
